import { reactive, onMounted, onBeforeUnmount } from 'vue'
export default function () {
    let data = reactive({
        x: 0,
        y: 0
    })

    let cb = function (event) {
        data.x = event.pageX
        data.y = event.pageY
        console.log(`鼠标定位X:${data.x}, Y:${data.y}`)
    }

    onMounted(() => {
        console.log('---开始监听鼠标点击事件---')
        window.addEventListener('click', cb)
    })

    onBeforeUnmount(() => {
        console.log('---移除监听鼠标点击事件---')
        window.removeEventListener('click', cb)
    })

    return data
}